package com.bestcem.xm.wallet.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 到期失效的 scheme 码失效类型
 *
 * @author wangyunyun <yunyun.wang@idiaoyan.com>
 * @version v1.0
 * @date 2022/5/23 10:11
 */
@Getter
@AllArgsConstructor
public enum ExpireTypeEnum {

    /**
     * 到期失效的 scheme 码失效类型
     */
    EXPIRE_TIME(0, "失效时间"),
    EXPIRE_INTERVAL(1, "失效间隔天数"),
    ;

    private Integer status;

    private String desc;

    /**
     * 通值获取枚举
     *
     * @param value 状态
     * @return ExpireTypeEnum
     * @author wangyunyun <yunyun.wang@idiaoyan.com>
     * @date 2022/5/17 15:11
     */
    public static ExpireTypeEnum getByValue(Integer value) {
        if (value == null) {
            return null;
        }
        return Stream.of(values()).filter(t -> t.getStatus().equals(value)).findFirst().orElse(null);
    }

}
